package com.probiz.estore.catalog.model;

import com.probiz.estore.core.model.BaseObject;

import java.io.Serializable;
import java.util.Set;
import java.util.LinkedHashSet;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;

/**
 * 所有目录类对象的基类，定义了目录的基本属性和操作方法
 * Created by Probiz
 * User: hoverming
 * Date: 2009-12-2
 * Time: 10:53:16
 */
public class BaseCategory extends BaseObject implements Serializable {
    private static final long serialVersionUID = -641242868829608108L;
    protected Integer categoryId;
    protected Short categoryType;
    protected String categoryCode;
    protected String categoryName;
    protected String categoryDescription;
    protected String keywords;
    protected String metaDescription;
    protected String templatePath;
    protected Short depth;
    protected Short hasChildren;
    protected String parentPath;
    protected String categoryPath;
    protected String imageUrl;
    protected Integer sortOrder;
    protected Short status;
    protected String displayFlag;
    protected Integer activeItemCount;
    protected Integer itemCount;
    protected boolean isParentFirstChild;    // 是否父目录的第一个Item
    protected boolean isParentLastChild;       // 是否父目录的最后一个Item
    protected Integer nextDifference = 0;      // 与下一个相差的级数
    protected Integer subIndex;        // 在父目录的index
    protected int level;   //级数
    protected Integer parentId;
    protected BaseCategory parent;
    protected Set<BaseCategory> children = new LinkedHashSet<BaseCategory>();


    public BaseCategory() {
    }

    /**
     * Default Key Fields Constructor for class ProductCategory
     *
     * @param in_categoryId 目录id
     */
    public BaseCategory(Integer in_categoryId) {
        this.setCategoryId(in_categoryId);
    }

    public Integer getParentId() {
        return parentId;
    }

    public void setParentId(Integer parentId) {
        this.parentId = parentId;
    }

    public BaseCategory getParent() {
        return parent;
    }

    public void setParent(BaseCategory parent) {
        this.parent = parent;
    }

    public Set<BaseCategory> getChildren() {
        return children;
    }

    public void setChildren(Set<BaseCategory> children) {
        this.children = children;
    }

    public Integer getCategoryId() {
        return categoryId;
    }

    public void setCategoryId(Integer categoryId) {
        this.categoryId = categoryId;
    }

    public Short getCategoryType() {
        return categoryType;
    }

    public void setCategoryType(Short categoryType) {
        this.categoryType = categoryType;
    }

    public String getCategoryCode() {
        return categoryCode;
    }

    public void setCategoryCode(String categoryCode) {
        this.categoryCode = categoryCode;
    }

    public String getCategoryName() {
        return categoryName;
    }

    public void setCategoryName(String categoryName) {
        this.categoryName = categoryName;
    }

    public String getCategoryDescription() {
        return categoryDescription;
    }

    public void setCategoryDescription(String categoryDescription) {
        this.categoryDescription = categoryDescription;
    }

    public String getKeywords() {
        return keywords;
    }

    public void setKeywords(String keywords) {
        this.keywords = keywords;
    }

    public String getMetaDescription() {
        return metaDescription;
    }

    public void setMetaDescription(String metaDescription) {
        this.metaDescription = metaDescription;
    }

    public String getTemplatePath() {
        return templatePath;
    }

    public void setTemplatePath(String templatePath) {
        this.templatePath = templatePath;
    }

    public Short getDepth() {
        return depth;
    }

    public void setDepth(Short depth) {
        this.depth = depth;
    }

    public Short getHasChildren() {
        return hasChildren;
    }

    public void setHasChildren(Short hasChildren) {
        this.hasChildren = hasChildren;
    }
    

    public String getParentPath() {
		return parentPath;
	}

	public void setParentPath(String parentPath) {
		this.parentPath = parentPath;
	}


	public String getCategoryPath() {
        return categoryPath;
    }

    public void setCategoryPath(String categoryPath) {
        this.categoryPath = categoryPath;
    }

    public String getImageUrl() {
        return imageUrl;
    }

    public void setImageUrl(String imageUrl) {
        this.imageUrl = imageUrl;
    }

    public Integer getSortOrder() {
        return sortOrder;
    }

    public void setSortOrder(Integer sortOrder) {
        this.sortOrder = sortOrder;
    }

    public Short getStatus() {
        return status;
    }

    public void setStatus(Short status) {
        this.status = status;
    }


    public String getDisplayFlag() {
        return displayFlag;
    }


    public void setDisplayFlag(String displayFlag) {
        this.displayFlag = displayFlag;
    }


    public Integer getActiveItemCount() {
        return activeItemCount;
    }

    public void setActiveItemCount(Integer activeItemCount) {
        this.activeItemCount = activeItemCount;
    }


    public Integer getItemCount() {
        return itemCount;
    }

    public void setItemCount(Integer itemCount) {
        this.itemCount = itemCount;
    }


    public static long getSerialVersionUID() {
        return serialVersionUID;
    }


    public boolean isParentFirstChild() {
        return isParentFirstChild;
    }

    public void setParentFirstChild(boolean isParentFirstChild) {
        this.isParentFirstChild = isParentFirstChild;
    }

    public boolean isParentLastChild() {
        return isParentLastChild;
    }

    public void setParentLastChild(boolean isParentLastChild) {
        this.isParentLastChild = isParentLastChild;
    }

    public Integer getNextDifference() {
        return nextDifference;
    }

    public void setNextDifference(Integer nextDifference) {
        this.nextDifference = nextDifference;
    }

    public Integer getSubIndex() {
        return subIndex;
    }

    public void setSubIndex(Integer subIndex) {
        this.subIndex = subIndex;
    }

    public int getLevel() {
        return level;
    }

    public void setLevel(int level) {
        this.level = level;
    }

    /**
     * @see java.lang.Object#equals(Object)
     */
    public boolean equals(Object object) {
        if (!(object instanceof BaseCategory)) {
            return false;
        }
        BaseCategory rhs = (BaseCategory) object;
        return new EqualsBuilder()
                .append(this.categoryId, rhs.categoryId)
                .append(this.categoryType, rhs.categoryType)
                .append(this.categoryCode, rhs.categoryCode)
                .append(this.categoryName, rhs.categoryName)
                .append(this.categoryDescription, rhs.categoryDescription)
                .append(this.keywords, rhs.keywords)
                .append(this.metaDescription, rhs.metaDescription)
                .append(this.templatePath, rhs.templatePath)
                .append(this.depth, rhs.depth)
                .append(this.hasChildren, rhs.hasChildren)
                .append(this.categoryPath, rhs.categoryPath)
                .append(this.imageUrl, rhs.imageUrl)
                .append(this.sortOrder, rhs.sortOrder)
                .append(this.status, rhs.status)
                .append(this.displayFlag, rhs.displayFlag)
                .append(this.itemCount, rhs.itemCount)
                .append(this.createBy, rhs.createBy)
                .append(this.updateBy, rhs.updateBy)
                .append(this.createTime, rhs.createTime)
                .append(this.updateTime, rhs.updateTime)
                .isEquals();
    }

    /**
     * @see java.lang.Object#hashCode()
     */
    public int hashCode() {
        return new HashCodeBuilder(-82280557, -700257973)
                .append(this.categoryId)
                .append(this.categoryType)
                .append(this.categoryCode)
                .append(this.categoryName)
                .append(this.categoryDescription)
                .append(this.keywords)
                .append(this.metaDescription)
                .append(this.templatePath)
                .append(this.depth)
                .append(this.hasChildren)
                .append(this.categoryPath)
                .append(this.imageUrl)
                .append(this.sortOrder)
                .append(this.status)
                .append(this.displayFlag)
                .append(this.itemCount)
                .append(this.createBy)
                .append(this.updateBy)
                .append(this.createTime)
                .append(this.updateTime)
                .toHashCode();
    }

    /**
     * @see java.lang.Object#toString()
     */
    public String toString() {
        return new ToStringBuilder(this)
                .append("categoryId", this.categoryId)
                .append("categoryType", this.categoryType)
                .append("categoryCode", this.categoryCode)
                .append("categoryName", this.categoryName)
                .append("categoryDescription", this.categoryDescription)
                .append("keywords", this.keywords)
                .append("metaDescription", this.metaDescription)
                .append("templatePath", this.templatePath)
                .append("depth", this.depth)
                .append("hasChildren", this.hasChildren)
                .append("categoryPath", this.categoryPath)
                .append("imageUrl", this.imageUrl)
                .append("sortOrder", this.sortOrder)
                .append("status", this.status)
                .append("displayFlag", this.displayFlag)
                .append("itemCount", this.itemCount)
                .append("nextDifference", this.nextDifference)
                .append("createBy", this.createBy)
                .append("updateBy", this.updateBy)
                .append("createTime", this.createTime)
                .append("updateTime", this.updateTime)
                .toString();
    }

    /**
     * Return the name of the first key column
     */
    public String getFirstKeyColumnName() {
        return "categoryId";
    }

    /**
     * Return the Id (pk) of the entity, must be Integer
     */
    public Integer getId() {
        return categoryId;
	}

}
